package cn.vq3.kmsaiserver.kmsaiserver.utils;

import lombok.extern.log4j.Log4j;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;

import java.io.*;
import java.util.HashMap;
import java.util.Map;

@Component
public class loadProperties {

    Logger logger = Logger.getLogger("loadProperties.class");
    public Map<String, Object> loadProperties(String filename) {
        // 读取 YAML 文件
        Map<String, Object> data = new HashMap<>();
        try (InputStream inputStream = new FileInputStream(filename)) {
            Yaml yaml = new Yaml();
            data = yaml.load(inputStream);
        } catch (IOException e) {
            logger.error(e);
            e.printStackTrace();
        }
        return data;
    }

 /*   private static boolean createData() {
        // 创建要写入的数据
        // ...
        return true;
    }*/
/*// 写入 YAML 文件
    public boolean saveProperties(String filename, Map<String, Object> data) {
        try (Writer writer = new FileWriter("output.yaml")) {
            Yaml yaml = new Yaml();
            Map<String, Object> data = createData();
            yaml.dump(data, writer);
        } catch (IOException e) {
            e.printStackTrace();
        }



    }*/

}
